/*
*
*	Valida E-mail
*
*/
jQuery(function($) {
	validaEmail($("#email").val());
});

function isEmail(email){
    
    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,3}$/;

    if(((email.search(exclude) != -1)||(email.search(check)) == -1)||(email.search(checkend) == -1)){
    	return false;
    }else {
    	return true;
    }
}


function validaEmail(valor){

	if(!valor.length == 0){
		if(!isEmail(valor)){
			$("#emailDiv").addClass("has-error");
		}else{
			$("#emailDiv").removeClass("has-error");
		}
	}else{
		$("#emailDiv").removeClass("has-error");
	}
};
